/*
 * @lc app=leetcode.cn id=2956 lang=golang
 *
 * [2956] 找到两个数组中的公共元素
 */
package Solutions

// @lc code=start
func findIntersectionValues(nums1 []int, nums2 []int) []int {
	mp1 := make(map[int]struct{}, len(nums1))
	mp2 := make(map[int]struct{}, len(nums2))
	for _, v := range nums1 {
		mp1[v] = struct{}{}
	}
	for _, v := range nums2 {
		mp2[v] = struct{}{}
	}
	an1, an2 := 0, 0
	for _, v := range nums1 {
		if _, ok := mp2[v]; ok {
			an1++
		}
	}
	for _, v := range nums2 {
		if _, ok := mp1[v]; ok {
			an2++
		}
	}
	return []int{an1, an2}
}

// @lc code=end
